<?php

namespace app\admin\controller;
use think\Db;
use app\common\service\BalanceService;
class Xieyi extends Common{

	/*
	隐私声明
	 */
	public function ysXy(){
		if (request()->method() == 'POST') {
			//$data['title'] = request()->param('title');
			//$data['time'] = request()->param('time');
			$content = input('post.content','',null);
			//return $data['content'];
			$res = Db::table('tp_system_param')->where('param','ys_xy')->update(['val'=>$content]);
			if ($res) {
				return ['code'=>0,'msg'=>'success'];
			} else {
				return ['code'=>1,'msg'=>'更新失败'];
			}			
		} else {
			$pravicy = Db::table('tp_system_param')->where('param','ys_xy')->value('val');
			$this->assign('pravicy',$pravicy);
			return $this->fetch();
		}
	}

	/*
	关于我们
	 */
	public function aboutUs(){
		if (request()->method() == 'POST') {
			//$data['title'] = request()->param('title');
			//$data['time'] = request()->param('time');
			$content = input('post.content','',null);
			//return $data['content'];
			$res = Db::table('tp_system_param')->where('param','about_us')->update(['val'=>$content]);
			if ($res) {
				return ['code'=>0,'msg'=>'success'];
			} else {
				return ['code'=>1,'msg'=>'更新失败'];
			}			
		} else {
			$pravicy = Db::table('tp_system_param')->where('param','about_us')->value('val');
			$this->assign('pravicy',$pravicy);
			return $this->fetch();
		}
	}

	/*
	帮助中心
	 */
	public function helpCenter(){
		if (request()->method() == 'POST') {
			//$data['title'] = request()->param('title');
			//$data['time'] = request()->param('time');
			$content = input('post.content','',null);
			//return $data['content'];
			$res = Db::table('tp_system_param')->where('param','help_center')->update(['val'=>$content]);
			if ($res) {
				return ['code'=>0,'msg'=>'success'];
			} else {
				return ['code'=>1,'msg'=>'更新失败'];
			}			
		} else {
			$pravicy = Db::table('tp_system_param')->where('param','help_center')->value('val');
			$this->assign('pravicy',$pravicy);
			return $this->fetch();
		}
	}
	/*
	服务协议
	 */
	public function serviceXy(){
		if (request()->method() == 'POST') {
			//$data['title'] = request()->param('title');
			//$data['time'] = request()->param('time');
			$content = input('post.content','',null);
			//return $data['content'];
			$res = Db::table('tp_system_param')->where('param','service_xy')->update(['val'=>$content]);
			if ($res) {
				return ['code'=>0,'msg'=>'success'];
			} else {
				return ['code'=>1,'msg'=>'更新失败'];
			}			
		} else {
			$pravicy = Db::table('tp_system_param')->where('param','service_xy')->value('val');
			$this->assign('pravicy',$pravicy);
			return $this->fetch();
		}
	}
	/*
	服务协议
	 */
	public function regXy(){
		if (request()->method() == 'POST') {
			//$data['title'] = request()->param('title');
			//$data['time'] = request()->param('time');
			$content = input('post.content','',null);
			//return $data['content'];
			$res = Db::table('tp_system_param')->where('param','reg_xy')->update(['val'=>$content]);
			if ($res) {
				return ['code'=>0,'msg'=>'success'];
			} else {
				return ['code'=>1,'msg'=>'更新失败'];
			}			
		} else {
			$pravicy = Db::table('tp_system_param')->where('param','reg_xy')->value('val');
			$this->assign('pravicy',$pravicy);
			return $this->fetch();
		}
	}
	/*
	店铺协议
	 */
	public function storeXy(){
		if (request()->method() == 'POST') {
			//$data['title'] = request()->param('title');
			//$data['time'] = request()->param('time');
			$content = input('post.content','',null);
			//return $data['content'];
			$res = Db::table('tp_system_param')->where('param','store_xy')->update(['val'=>$content]);
			if ($res) {
				return ['code'=>0,'msg'=>'success'];
			} else {
				return ['code'=>1,'msg'=>'更新失败'];
			}			
		} else {
			$pravicy = Db::table('tp_system_param')->where('param','store_xy')->value('val');
			$this->assign('pravicy',$pravicy);
			return $this->fetch();
		}
	}
}